package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.Doctorinfo;
import com.ruoyi.system.service.IDoctorinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医生档案Controller
 * 
 * @author gzhuangwei
 * @date 2022-09-17
 */
@Api("医生信息管理")
@RestController
@RequestMapping("/business/doctorinfo")
public class DoctorinfoController extends BaseController
{
    @Autowired
    private IDoctorinfoService doctorinfoService;

    /**
     * 查询医生档案列表
     */
    @PreAuthorize("@ss.hasPermi('business:doctorinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(Doctorinfo doctorinfo)
    {
        startPage();
        List<Doctorinfo> list = doctorinfoService.selectDoctorinfoList(doctorinfo);
        return getDataTable(list);
    }

    /**
     * 导出医生档案列表
     */
    @PreAuthorize("@ss.hasPermi('business:doctorinfo:export')")
    @Log(title = "医生档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Doctorinfo doctorinfo)
    {
        List<Doctorinfo> list = doctorinfoService.selectDoctorinfoList(doctorinfo);
        ExcelUtil<Doctorinfo> util = new ExcelUtil<Doctorinfo>(Doctorinfo.class);
        util.exportExcel(response, list, "医生档案数据");
    }

    /**
     * 获取医生档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:doctorinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(doctorinfoService.selectDoctorinfoById(id));
    }

    /**
     * 新增医生档案
     */
    @PreAuthorize("@ss.hasPermi('business:doctorinfo:add')")
    @Log(title = "医生档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Doctorinfo doctorinfo)
    {
        return toAjax(doctorinfoService.insertDoctorinfo(doctorinfo));
    }

    /**
     * 修改医生档案
     */
    @PreAuthorize("@ss.hasPermi('business:doctorinfo:edit')")
    @Log(title = "医生档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Doctorinfo doctorinfo)
    {
        return toAjax(doctorinfoService.updateDoctorinfo(doctorinfo));
    }

    /**
     * 删除医生档案
     */
    @PreAuthorize("@ss.hasPermi('business:doctorinfo:remove')")
    @Log(title = "医生档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorinfoService.deleteDoctorinfoByIds(ids));
    }

    /**
     * 1.4.1
     * 返回医生档案列表
     */
    @ApiOperation("查询医生档案列表")
    @GetMapping("/doctorList")
    public AjaxResult doctorList(Doctorinfo doctorinfo)
    {
        List<Doctorinfo> list = doctorinfoService.selectDoctorinfoList(doctorinfo);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("equipmentList", list);

        return ajax;
    }
    /**
     * 1.4.2
     * 通过医生id查询医生
     */
    @ApiOperation("通过医生id查询医生")
    @GetMapping("/getByDoctorId")
    public AjaxResult getByDoctorId(@RequestParam("doctorId") String doctorId)
    {
        return AjaxResult.success(doctorinfoService.selectByDoctorId(doctorId));
    }
}
